﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<script type="text/javascript">
    var keyValue = $.request("keyValue");
    var F_ClientId = $.request("F_ClientId");
    $(function () {
        getItemList();
        getEntity();
    });

    function getEntity() {
        $.ajax({
            url: "/MyTask/MySalesReport/GetVisitEntity?keyValue=" + keyValue,
            dataType: "json",
            async: false,
            success: function (data) {
                $("#form1").formSerialize(data);
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }

    function getItemList() {
        $.ajax({
            url: "/MyTask/MySalesReport/GetItemList",
            dataType: "json",
            async: false,
            success: function (data) {
                initControl(data)
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }

    function initControl(data) {
        var gszw = data.gszw;
        for (var i = 0; i < gszw.length; i++) {
            $("#F_PositionId").append("<option value='" + gszw[i].F_ItemCode + "'>" + gszw[i].F_ItemName + "</option>");
        }
        var hdjd = data.hdjd;
        for (var i = 0; i < hdjd.length; i++) {
            $("#F_Progress").append("<option value='" + hdjd[i].F_ItemCode + "'>" + hdjd[i].F_ItemName + "</option>");
        }
    }

    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        var params = $("#form1").formSerialize();
        $.submitForm({
            url: "/MyTask/MySalesReport/SubmitVisitForm?keyValue=" + keyValue + "&F_ClientId=" + F_ClientId,
            param: params,
            success: function () {
                $.currentWindow().$("#gridListRecord").trigger("reloadGrid");
            }
        })
    }
</script>
<form id="form1">
    <div style="padding-top: 20px;">
        <table id="form1" class="form" style="margin-top:3px;">
            <tr>
                <td colspan="6" class="interval">拜访信息</td>
            </tr>
            <tr>
                <td class="formTitle">对接人</td>
                <td class="formValue"><input id="F_DockingName" name="F_DockingName" type="text" maxlength="50" class="form-control required" placeholder="请录入对接人" /></td>
                <td class="formTitle">手机号</td>
                <td class="formValue">
                    <input id="F_Phone" name="F_Phone" type="text" class="form-control required" maxlength="11" minlength="11" placeholder="请录入手机号" />
                </td>
                <td class="formTitle">公司职位</td>
                <td class="formValue">
                    <select id="F_PositionId" name="F_PositionId" class="form-control required">
                        <option value="">==请选择公司职位==</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="formTitle">工作进度</td>
                <td class="formValue">
                    <select id="F_Progress" name="F_Progress" class="form-control required">
                        <option value="">==请选择进度==</option>
                    </select>
                </td>
                <td class="formTitle">行动计划</td>
                <td class="formValue">
                    <input id="F_Action" name="F_Action" type="text" class="form-control required" maxlength="200" placeholder="请录入行动计划" />
                </td>
                <td class="formTitle">行动日期</td>
                <td class="formValue">
                    <input id="F_ActionDate" name="F_ActionDate" type="text" class="form-control required input-wdatepicker" onfocus="WdatePicker()" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">目标</td>
                <td class="formValue" colspan="5">
                    <textarea id="F_Target" name="F_Target" class="form-control required" maxlength="200" placeholder="请录入目标"></textarea>
                </td>
            </tr>
            <tr>
                <td class="formTitle">指标备注</td>
                <td class="formValue" colspan="5">
                    <textarea id="F_IndexRemark" name="F_IndexRemark" class="form-control" maxlength="200" placeholder="请录入指标备注"></textarea>
                </td>
            </tr>
        </table>
    </div>
</form>
